Skip to content

fix: cache FDv2 polling ETags after parsing - #306

Open
pcbeingused33 wants to merge 1 commit into
launchdarkly:mainfrom
pcbeingused33:fix/fdv2-polling-etag-c9036
Open

pcbeingused33 wants to merge 1 commit into
launchdarkly:mainfrom
pcbeingused33:fix/fdv2-polling-etag-c9036

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Related fix in the Ruby SDK: launchdarkly/ruby-server-sdk#515

Describe the solution you've provided

FDv2 polling cached the ETag from a successful HTTP response before reading and parsing its body. If parsing failed, the next poll for the same URI could send the rejected payload's ETag and receive a 304, leaving the SDK on stale flag data.

Update the ETag cache after the payload parses successfully. The regression test sends malformed JSON with an ETag, then polls the same URI and checks that the rejected ETag is absent from the request and the valid response is parsed.

Describe alternatives you've considered

Clearing the cached ETag on a payload error would force a full response on the next poll. Delaying the cache update preserves the validator for the last successfully parsed response.

Additional context

The regression failed with the original requestor because the second poll sent If-None-Match: invalid-etag. All 21 tests in DefaultFDv2RequestorTest passed with the fix on Temurin 17, targeting Java 8.

This change was prepared with AI assistance (Codex).


Note

Overview
FDv2 polling no longer stores response ETags until the body parses successfully as flag events.

Previously, a 200 with bad JSON could still cache the ETag, so the next poll might send If-None-Match and get 304 Not Modified, leaving the SDK on stale flag data. ETag updates now run only after FDv2Event.parseEventsArray succeeds.

A new regression test (invalidJsonDoesNotCacheEtag) asserts that a malformed JSON response with an ETag does not affect later polls and that a valid follow-up response is parsed normally.

Reviewed by Cursor Bugbot for commit 401ee19. Bugbot is set up for automated code reviews on this repo. Configure here.

@pcbeingused33
pcbeingused33 requested a review from a team as a code owner December 4, 2026 03:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant